package com.xjscrm.server.biz.mq.hander;

import com.uzai.mobile.collect.api.dto.MicaTransDto;
import com.uzai.mobile.collect.api.enums.MicaMsgType;
import com.xjscrm.server.service.tasktagauto.TaskTagAutoService;
import com.xjscrm.server.service.wwgroup.WwGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

/**
 * 群会话变更消息类型实现类
 *
 * @author liuqi
 * @date 2024年03月01日 15:24
 */
@Component
@Slf4j
public class ConversationChangeConsumerHandlerImpl implements ConsumerHandler {

    @Autowired
    private WwGroupService wwGroupService;

    @Override
    public MicaMsgType msgType() {
        return MicaMsgType.CONVERSATION_CHANGE;
    }

    @Override
    public void handle(MicaTransDto micaTransDto) {

        try {
            if (micaTransDto.getMerId() == null) {
                log.info("数据未传merId");
                return;
            }

            //同步企业微信通讯录
            if (micaTransDto.qwechatDevice()) {
                //处理进群退群业务
                wwGroupService.wwGroupChange(micaTransDto);
            } else if (micaTransDto.wechatDevice()) { //个人微信
                log.info("暂时不支持个人微信类型业务");
            } else {
                log.info("暂时不支持该设备类型业务");
            }
        }catch (Exception e){
            log.error(this.msgType().getDesc() + " is error:{}", e.getMessage());
        }
    }
}
